'''
Author: linxuan
Date: 2022-07-17 19:01:58
Description: file content
FilePath: /stealer/src/zora_co_upload.py
'''


import json
import os
from time import sleep

from upload import upload


def main():
    # 遍历 /resources/zora.audio下所有的json文件
    path = '/resources/zora.music/'[1:]
    for file in os.listdir(path):
        if file.endswith(".json"):
            # 读取文件内容
            with open(path + file, "r") as f:
                params = json.load(f)
                params['type'] = 'music'
            # 调用上传接口
            if len(params) > 5:
                status_code, text = upload(params)
                # 打印返回结果
                if status_code == 200:
                    print("upload success: " + file)
                    sleep(0.2)
                else:
                    print(f"{file} error", text)


if __name__ == "__main__":
    main()
